// models/collection.go
package model

import (
	"encoding/json"
	"time"
)

type CollectionRecord struct {
	CollectionID        string          `json:"collection_id" gorm:"type:char(36);primaryKey;column:collection_id"`
	LocationID          string          `json:"location_id" gorm:"not null"`
	FirstCollectionTime time.Time       `json:"first_collection_time" gorm:"not null;index"`
	LastUpdateTime      time.Time       `json:"last_update_time" gorm:"autoUpdateTime;not null"`
	CollectorAccount    string          `json:"collector_account" gorm:"not null"`
	DataPathHash        json.RawMessage `json:"data_path_hash" gorm:"not null;type:json"`
	Thumbnail           []byte          `json:"thumbnail" gorm:"type:longblob"`
	Feedback            json.RawMessage `json:"feedback" gorm:"type:json"`
	ReviewStatus        int8            `json:"review_status" gorm:"type:tinyint;not null;default:0"`

	// 关联
	Location  Location `json:"-" gorm:"foreignKey:LocationID"`
	Collector User     `json:"-" gorm:"foreignKey:CollectorAccount"`
}

type SingleRecord struct {
	CollectionID      string    `json:"collectionID"`
	CollectorNickName string    `json:"collectorNickName"` // 从 User 表关联获取
	LastUpdateTime    time.Time `json:"lastUpdateTime"`
	Thumbnail         []byte    `json:"thumbnail"`
}

func (c *CollectionRecord) TableName() string {
	return "collection_record"
}
